<!--
 * @Description: 设计资源评价台账
 * @Author: wind-lc
 * @version: 1.0
 * @Date: 2021-08-30 11:26:57
 * @LastEditTime: 2021-09-07 16:17:02
 * @FilePath: \cscec-pms-admin\src\views\design\resource\projectLedger\index.vue
-->
<template>
  <base-breadcrumb :title="$route.meta.title">
    <!-- 搜索 -->
    <searchData
      :search-data="searchOption"
      @search="search"
    />
    <!-- 搜索 -->
    <a-card>
      <!-- <title-name title="设计资源评价台账" /> -->
      <!-- 台账 -->
      <list-table
        ref="table"
        :columns="columns"
        :request="loadData"
        :page-keys=" ['pageNum', 'pageSize', 'totalSize']"
        :export-config="{ use: true,select: '设计资源评价台账',all: '设计资源评价台账'}"
        :is-show-count-bar="false"
      >
        <span
          slot="operation"
          slot-scope="text,record"
        >
          <template>
            <a @click="handleView(record)">查看</a>
          </template>
        </span>
      </list-table>
      <!-- 台账 -->
    </a-card>
  </base-breadcrumb>
</template>
<script>
import { searchOption, columns } from './model.js'
import projectLedger from '@/api/design/projectLedger'
export default {
  name: 'ProjectLedger',
  components: {},
  data() {
    return {
      // 搜索选项
      searchOption,
      // 查询参数
      searchData: {},
      // 表头
      columns,
      // 表格数据加载
      loadData: async (q) => {
        const params = Object.assign(
          {
            pageNo: q.pageNum,
            pageSize: q.pageSize
          },
          { query: this.searchData }
        )
        const res = await projectLedger.ledger(params)
        if (res.code === 200) {
          return { code: 200, data: res.data, ...res }
        }
        return { code: 200, data: [] }
      }
    }
  },
  methods: {
    /**
     * @description: 搜索
     * @param {Object} value 搜索数据
     * @return {Void}
     */
    search(value) {
      this.searchData = value || {}
      this.$refs.table.getData(null, true)
    },
    /**
     * @description: 查看
     * @param {Object} record 行数据
     * @return {Void}
     */
    handleView(record) {
      const { id, designResourceName, designResourceType, year, averageScorePd, averageScoreBc, averageScoreCo } =
        record
      this.$router.push({
        path: '/project/design/projectLedger/projectLedgerDetail',
        query: {
          id,
          designResourceName,
          designResourceType,
          year,
          averageScorePd,
          averageScoreBc,
          averageScoreCo
        }
      })
    }
  }
}
</script>
<style lang="less" scoped>
</style>
